<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>活动列表</title>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/show/css/font.css">
    <link rel="stylesheet" href="/show/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="/show/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/show/js/xadmin.js"></script>

</head>
<body>
<br>
<div class="layui-input-inline">
    <form class="layui-form" action="/activity/retrieveSearch" method="post">
        <div class="demoTable">
            <span style="font-size: 15px">搜索:&nbsp;&nbsp;&nbsp;</span>
            <div class="layui-input-inline">
            <span >
                <select id="searchKey" layui-filter="key" name="searchKey">
                    <option value>--请选择--</option>
                    <option th:if="${list.searchKey} eq activityId" value="activityId" selected>节目编号</option>
                    <option th:if="${list.searchKey} ne activityId" value="activityId" >节目编号</option>

                    <option th:if="${list.searchKey} eq activityName" value="activityName" selected>表演节目名</option>
                    <option th:if="${list.searchKey} ne activityName" value="activityName" >表演节目名</option>

                    <option th:if="${list.searchKey} eq activityAddr" value="activityAddr" selected>所属区域</option>
                    <option th:if="${list.searchKey} ne activityAddr" value="activityAddr" >所属区域</option>

                    <option th:if="${list.searchKey} eq activityArea" value="activityArea" selected>表演地点</option>
                    <option th:if="${list.searchKey} ne activityArea" value="activityArea">表演地点</option>

                    <option th:if="${list.searchKey} eq dayTime" value="dayTime" selected>表演场次</option>
                    <option th:if="${list.searchKey} ne dayTime" value="dayTime">表演场次</option>

                </select>
            </span>
            </div>
            <div class="layui-input-inline">
            <span>
                <input type="text" class="layui-input" name="searchValue" id="searchValue" autocomplete="off"
                       placeholder="输入关键字" th:value="${list.searchValue}">
            </span>
            </div>
            <button class="layui-btn" data-type="reload" lay-filter="search" lay-submit="">搜索</button>
        </div>
    </form>
</div>
<hr>
<button class="layui-btn" type="button" id="delMany" onclick="resumeMany()"><i class="layui-icon">&#xe64f;</i>批量恢复</button>
<hr>
<div>
    <span style="font-size: 25px">搜索结果</span>
</div>
<hr>
<table class="layui-table" id="planTable">
    <thead>
    <tr>
        <th class="th-check">
            <input type="checkbox" lay-skin="success" name="selectAll"></input>
        </th>
        <th>节目编号</th>
        <th>表演节目名</th>
        <th>表演地点</th>
        <th>所属区域</th>
        <th>表演场次</th>
        <th>操作</th>
    </thead>

    <tbody>
    <tr th:each="act:${list.activityList}" id="tr-act">
        <td class="td-check" >
            <input type="checkbox" lay-skin="success" name="checkbox" th:activityId="${act.activityId}" >
        </td>
        <td name="td-id" th:text="${act.activityId}"></td>
        <td th:text="${act.activityName}"></td>
        <td th:text="${act.activityArea}"></td>
        <td th:text="${act.activityAddr}"></td>

        <td class="td-time" th:if="${act.dayTime==1}">
            白天场
        </td>
        <td class="td-time" th:if="${act.dayTime==2}">
            夜间场
        </td>

        <td class="td-manage" >
            <a title="恢复" onclick="resume(this)" href="javascript:;">
                <i class="layui-icon">&#xe64f;</i>
            </a>
        </td>
    </tr>
    </tbody>
</table>
<div class="page">
    <div>
        <a class="prev" th:href="@{/activity/retrieveSearch(page=${list.prePage},searchKey=${list.searchKey},searchValue=${list.searchValue})}">&lt;&lt;</a>
        <a class="num" th:href="@{/activity/retrieveSearch(searchKey=${list.searchKey},searchValue=${list.searchValue})}">首页</a>
        <span class="current" th:text="${list.curPage}"></span>
        <a class="num" th:href="@{/activity/retrieveSearch(page=${list.totalPage},searchKey=${list.searchKey},searchValue=${list.searchValue})}">尾页</a>
        <a class="next" th:href="@{/activity/retrieveSearch(page=${list.nextPage},searchKey=${list.searchKey},searchValue=${list.searchValue})}">&gt;&gt;</a>
    </div>
</div>
<script>

    //全选
    $('input:checkbox[name="selectAll"]').click(function(){
        if($(this).is(':checked')){
            $('input:checkbox').each(function(){
                $(this).prop("checked",true);
            });
        }else{
            $('input:checkbox').each(function(){
                $(this).prop("checked",false);
            });
        }
    });

    //批量恢复
    function resumeMany() {
        var ids = '';
        $('[name=checkbox]').each(function () {
            if (this.checked == true) {
                ids += $(this).attr("activityId") + ',';
            }
        });
        if (ids) {
            layer.confirm('是否恢复已选定内容', function (index) {
                $.ajax({
                    url: "/activity/resumeMany",
                    async: false,
                    type: "POST",
                    dataType: "json",
                    data: {"ids": ids},
                    success: function (data) {
                        if (data.info == "success") {
                            layer.close(index);
                            //刷新
                            window.location.replace("/activity/retrieve")
                        } else {
                            layer.msg(data.info, {icon: 5, time: 1000});
                        }
                    }
                })
            });
        }else {
            layer.msg("请选择恢复内容",{icon: 7,time:1000});//7
        }
    }

    //单个活动删除
    function resume(obj) {
        //访问恢复页面地址
        var url = '/activity/resume';
        var activityId =$(obj).parents("tr").find("td").eq(1).text();
        var activityName =$(obj).parents("tr").find("td").eq(2).text();
        layer.confirm('是否恢复 '+activityName+' 节目?', function(index){
            $.ajax({
                url: url,
                async: false,
                type: "POST",
                dataType: "json",
                data: {"activityId":activityId},
                success: function (data) {
                    if (data.info=="success"){
                        layer.close(index);
                        //刷新
                        window.location.replace("/activity/retrieve")
                    }else {
                        layer.msg('恢复失败!',{icon: 5,time:1000});
                    }
                }
            })
        });
    }
</script>

</body>
</html>